import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:palmf_hid/common/style/style.dart';
import 'package:palmf_hid/common/values/values.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

/// 输入框
Widget inputTextEdit(
    {TextEditingController? controller,
    TextInputType keyboardType = TextInputType.text,
    String? hintText,
    bool isPassword = false,
    int? maxLines = 1,
    String? counterText = "",
    int? maxLength = TextField.noMaxLength,
    bool autofocus = false,
    TextInputAction? textInputAction = TextInputAction.done,
    FocusNode? focusNode,
    double? hintFontSize = 14,
    double? fontSize = 14,
    List<TextInputFormatter>? inputFormatters}) {
  return TextField(
    focusNode: focusNode,
    autofocus: autofocus,
    controller: controller,
    keyboardType: keyboardType,
    decoration: InputDecoration(
        isCollapsed: true,
        hintText: hintText,
        fillColor: MyColor.c_FF999999,
        hintStyle: TextStyle(color: Colors.grey, fontSize: hintFontSize),
        contentPadding: const EdgeInsets.fromLTRB(0, 0, 0, 0),
        border: InputBorder.none,
        counterText: counterText),
    inputFormatters: inputFormatters,
    style: TextStyle(
      color: AppColors.primaryText,
      fontFamily: "Avenir",
      fontWeight: FontWeight.w400,
      fontSize: fontSize,
    ),
    maxLines: maxLines,
    maxLength: maxLength,
    autocorrect: false,
    cursorHeight: 14,
    cursorColor: MyColor.account_color,
    // 自动纠正
    obscureText: isPassword, // 隐藏输入内容, 密码框
  );
}

/// email 输入框
/// 背景白色，文字黑色，带阴影
Widget inputEmailEdit(
    {TextEditingController? controller,
    TextInputType keyboardType = TextInputType.text,
    String? hintText,
    bool isPassword = false,
    double marginTop = 15,
    bool autofocus = false,
    TextInputAction? textInputAction = TextInputAction.done}) {
  return Container(
    height: 44.h,
    margin: EdgeInsets.only(top: marginTop.h),
    decoration: const BoxDecoration(
      color: AppColors.primaryBackground,
      borderRadius: Radii.k6pxRadius,
      boxShadow: [
        BoxShadow(
          color: Color.fromARGB(41, 0, 0, 0),
          offset: Offset(0, 1),
          blurRadius: 0,
        ),
      ],
    ),
    child: TextField(
      autofocus: autofocus,
      controller: controller,
      textInputAction: textInputAction,
      keyboardType: keyboardType,
      decoration: InputDecoration(
        hintText: hintText,
        contentPadding: const EdgeInsets.fromLTRB(20, 10, 0, 9),
        border: InputBorder.none,
        hintStyle: const TextStyle(
          color: AppColors.primaryText,
        ),
      ),
      style: TextStyle(
        color: AppColors.primaryText,
        fontFamily: "Avenir",
        fontWeight: FontWeight.w400,
        fontSize: 18,
      ),
      maxLines: 1,
      autocorrect: false,
      // 自动纠正
      obscureText: isPassword, // 隐藏输入内容, 密码框
    ),
  );
}
